/**
 * 
 */
package gameMiniGames;
import javax.imageio.ImageIO;
import gameUtils.*;
import gameExceptions.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
/**
 * @author Logical Solutions
 *
 */
public class TowerHotspot {
	
	public BufferedImage hotspot;
	public Towers tower;
	private LockedSelectionStackNode temp;
	
	//Calls the single instance of Towers
	public TowerHotspot(Towers INSTANCE){
		this.tower = INSTANCE;
		hotspot = setHotspot();
	}
	
	public BufferedImage setHotspot(){
		try{
			BufferedImage hotspot1 = ImageIO.read(new File("src/gameMiniGames/TowerImages/TowersHotSpot.jpg"));
			System.out.println("Hotspot Loaded");
			return hotspot1;
		}catch(IOException $e){
			System.err.println("Problem with the reading of file"+ $e.getMessage());
		}
		return null;
	}
	
	public void Intersects(Coordinate point){
		
		System.out.println(Integer.toHexString(hotspot.getRGB(point.xPos, point.yPos)));
		switch(hotspot.getRGB(point.xPos, point.yPos)){
		//For Mac Computers
		case 0xFF656767: // For stack 1
		{
			System.out.println("0xFF656767");
			System.out.println(tower.DragComponent.toString());
			if (!tower.PegOne.isEmpty()){
				if(tower.DragComponent == tower.PegOne.peek().piece){
					tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegOne.peek().nodeValue - 5), tower.draggedFrom.yPos- tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					tower.DragComponent = null;
					tower.draggedFrom = null;
					System.out.println(tower.PegOne.toString());
				}
			}
			if(!tower.PegTwo.isEmpty()){
				if(tower.DragComponent == tower.PegTwo.peek().piece){
					try{
						System.out.println(tower.PegTwo.toString());
						temp = tower.PegTwo.peek();
						tower.PegTwo.pop();
						System.out.println("popped from two");
						temp.stackNumber = 1;
						tower.PegOne.push(temp);
						System.out.println("pushed into one");
						System.out.println(tower.PegOne.toString());
						System.out.println(tower.PegOne.topEntity);
						
						System.out.println("two");
						System.out.println(tower.PegTwo.toString());
						
					}catch(EmptyStackException _$e){
						System.err.println("Empty Stack exception... check code"+"\n"+ _$e.getMessage());
						return;
					}catch(MinLockException _$e){
						tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegTwo.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
						try{
							if(tower.PegTwo.isEmpty()){
								temp.stackNumber = 2;
								tower.PegTwo.topEntity = temp;
								tower.PegTwo.size++;
							}else{
								tower.PegTwo.peek().setNextNode(temp);
								temp.stackNumber = 2;
								tower.PegTwo.push(temp);
							}
						}catch(MinLockException _$f){
							System.out.println("We have a BIG PROBLEM");
						}
						return;
					}
					tower.DragComponent.setBounds(tower.pegOneX-5*(tower.PegOne.peek().nodeValue-5), tower.gameYpos - 25*(tower.PegOne.size-1)-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					
					tower.DragComponent = null;
					tower.draggedFrom = null;	
				}
			}
				if(!tower.PegThree.isEmpty()){
					if(tower.DragComponent == tower.PegThree.peek().piece){
						try{
							System.out.println(tower.PegThree.toString());
							temp = tower.PegThree.peek();
							tower.PegThree.pop();
							System.out.println("popped from three");
							temp.stackNumber = 1;
							tower.PegOne.push(temp);
							System.out.println("pushed into one");
							System.out.println(tower.PegOne.toString());
							System.out.println(tower.PegOne.topEntity);
							
							System.out.println("three");
							System.out.println(tower.PegThree.toString());
							
						}catch(EmptyStackException _$e){
							System.err.println("Empty Stack exception... check code"+"\n"+ _$e.getMessage());
							return;
						}catch(MinLockException _$e){
							tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegThree.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
							try{
								if(tower.PegThree.isEmpty()){
									temp.stackNumber = 3;
									tower.PegThree.topEntity = temp;
									tower.PegThree.size++;
								}else{
									tower.PegThree.peek().setNextNode(temp);
									temp.stackNumber = 3;
									tower.PegThree.push(temp);
								}
							}catch(MinLockException _$f){
								System.out.println("We have a BIG PROBLEM");
							}
							return;
						}
						tower.DragComponent.setBounds(tower.pegOneX-5*(tower.PegOne.peek().nodeValue-5), tower.gameYpos - 25*(tower.PegOne.size-1)-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
						
						tower.DragComponent = null;
						tower.draggedFrom = null;	
					}
					
				}
			temp = null;
			break;
		}
		case 0xFF3F4040: // For stack 2
		{
			System.out.println("0xFF3F4040");
			if(!tower.PegOne.isEmpty()){
				if(tower.DragComponent == tower.PegOne.peek().piece){
					try{
						System.out.println(tower.PegOne.toString());
						temp = tower.PegOne.peek();
						tower.PegOne.pop();
						System.out.println("popped from one");
						temp.stackNumber = 2;
						tower.PegTwo.push(temp);
						System.out.println("pushed into two");
						System.out.println(tower.PegTwo.toString());
						System.out.println(tower.PegTwo.topEntity);
						
						System.out.println("one");
						System.out.println(tower.PegOne.toString());
						
					}catch(EmptyStackException _$e){
						System.err.println("Empty Stack exception... check code"+"\n"+ _$e.getMessage());
						return;
					}catch(MinLockException _$e){
						tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegOne.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
						try{
							if(tower.PegOne.isEmpty()){
								temp.stackNumber = 1;
								tower.PegOne.topEntity = temp;
								tower.PegOne.size++;
								System.out.println(tower.PegOne.toString());
								System.out.println(tower.PegOne.topEntity);
							}else{
								tower.PegOne.peek().setNextNode(temp);
								temp.stackNumber = 1;
								tower.PegOne.push(temp);
							}
						}catch(MinLockException _$f){
							System.out.println("We have a BIG PROBLEM");
						}
						return;
					}
					tower.DragComponent.setLocation(tower.pegTwoX-5*(tower.PegTwo.peek().nodeValue-5), tower.gameYpos - 25*(tower.PegTwo.size-1)-tower.yAdjustment);
					
					tower.DragComponent = null;
					tower.draggedFrom = null;
				}
			}
			if(!tower.PegTwo.isEmpty()){
				if(tower.DragComponent == tower.PegTwo.peek().piece){
					tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegTwo.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					tower.DragComponent = null;
					tower.draggedFrom = null;
					System.out.println(tower.PegTwo.toString());
				}
			}
			if(!tower.PegThree.isEmpty()){
				if(tower.DragComponent == tower.PegThree.peek().piece){
					try{
						System.out.println(tower.PegThree.toString());
						temp = tower.PegThree.peek();
						tower.PegThree.pop();
						System.out.println("popped from three");
						temp.stackNumber = 2;
						tower.PegTwo.push(temp);
						System.out.println("pushed into two");
						System.out.println(tower.PegTwo.toString());
						System.out.println(tower.PegTwo.topEntity);
						
						System.out.println("three");
						System.out.println(tower.PegThree.toString());
						
					}catch(EmptyStackException _$e){
						System.err.println("Empty Stack exception... check code"+"\n"+ _$e.getMessage());
						return;
					}catch(MinLockException _$e){
						tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegThree.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
						try{
							if(tower.PegThree.isEmpty()){
								temp.stackNumber = 3;
								tower.PegThree.topEntity = temp;
								tower.PegThree.size++;
								
							}else{
								tower.PegThree.peek().setNextNode(temp);
								temp.stackNumber = 3;
								tower.PegThree.push(temp);
							}
						}catch(MinLockException _$f){
							System.out.println("We have a BIG PROBLEM");
						}
						return;
					}
				
					tower.DragComponent.setBounds(tower.pegTwoX-5*(tower.PegTwo.peek().nodeValue-5), tower.gameYpos - 25*(tower.PegTwo.size-1)-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					
					tower.DragComponent = null;
					tower.draggedFrom = null;	
				}
				
			}
			temp = null;
			break;
			
		}
		
		case 0xFF000001: // For stack 3
		{
			System.out.println("0xFF000001");
			if(!tower.PegOne.isEmpty()){
				if(tower.DragComponent == tower.PegOne.peek().piece){
					try{
						System.out.println(tower.PegOne.toString());
						temp = tower.PegOne.peek();
						tower.PegOne.pop();
						System.out.println("popped from one");
						temp.stackNumber = 3;
						tower.PegThree.push(temp);
						System.out.println("pushed into three");
						System.out.println(tower.PegThree.toString());
						System.out.println(tower.PegThree.topEntity);
						
						System.out.println("one");
						System.out.println(tower.PegOne.toString());
						
					}catch(EmptyStackException _$e){
						System.err.println("Empty Stack exception... check code"+"\n"+ _$e.getMessage());
						return;
					}catch(MinLockException _$e){
						tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegOne.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
						try{
							if(tower.PegOne.isEmpty()){
								temp.stackNumber = 1;
								tower.PegOne.topEntity = temp;
								tower.PegOne.size++;
							}else{
								tower.PegOne.peek().setNextNode(temp);
								temp.stackNumber = 1;
								tower.PegOne.push(temp);
							}
						}catch(MinLockException _$f){
							System.out.println("We have a BIG PROBLEM");
						}
						return;
					}
					tower.DragComponent.setBounds(tower.pegThreeX-5*(tower.PegThree.peek().nodeValue-5), tower.gameYpos - 25*(tower.PegThree.size-1)-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					
					tower.DragComponent = null;
					tower.draggedFrom = null;	
				}
			}
			if(!tower.PegThree.isEmpty()){
				if(tower.DragComponent == tower.PegThree.peek().piece){
					tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegThree.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					tower.DragComponent = null;
					tower.draggedFrom = null;
					System.out.println(tower.PegThree.toString());
				}
			}
			if(!tower.PegTwo.isEmpty()){
				if(tower.DragComponent == tower.PegTwo.peek().piece){
					try{
						System.out.println(tower.PegTwo.toString());
						temp = tower.PegTwo.peek();
						tower.PegTwo.pop();
						System.out.println("popped from two");
						temp.stackNumber = 3;
						tower.PegThree.push(temp);
						System.out.println("pushed into three");
						System.out.println(tower.PegThree.toString());
						System.out.println(tower.PegThree.topEntity);
						
						System.out.println("two");
						System.out.println(tower.PegTwo.toString());
						
					}catch(EmptyStackException _$e){
						System.err.println("Empty Stack exception... check code"+"\n"+ _$e.getMessage());
						return;
					}catch(MinLockException _$e){
						tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegTwo.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
						try{
							if(tower.PegTwo.isEmpty()){
								temp.stackNumber = 2;
								tower.PegTwo.topEntity = temp;
								tower.PegTwo.size++;
							}else{
								tower.PegTwo.peek().setNextNode(temp);
								temp.stackNumber = 2;
								tower.PegTwo.push(temp);
							}
						}catch(MinLockException _$f){
							System.out.println("We have a BIG PROBLEM");
						}
						return;
					}
					tower.DragComponent.setBounds(tower.pegThreeX-5*(tower.PegThree.peek().nodeValue-5), tower.gameYpos - 25*(tower.PegThree.size-1)-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					
					tower.DragComponent = null;
					tower.draggedFrom = null;
				}
					
			}
			temp = null;
			break;
			
		}
		case 0xFFcFdFFe: // Whoops... i missed...
		{
			System.out.println("0xFFCFDFFE");
			if(tower.DragComponent == null){
				System.out.println("Ive got nothing");
				break;
			}
			tower.DragComponent.setBounds(tower.draggedFrom.xPos-tower.xAdjustment, tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
			tower.DragComponent = null;
			tower.draggedFrom = null;
			break;
		}
		
		
		//For Windows Computers
		case 0xFF676767: // For stack 1
		{
			System.out.println("0xFF656767");
			System.out.println(tower.DragComponent.toString());
			if (!tower.PegOne.isEmpty()){
				if(tower.DragComponent == tower.PegOne.peek().piece){
					tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegOne.peek().nodeValue - 5), tower.draggedFrom.yPos- tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					tower.DragComponent = null;
					tower.draggedFrom = null;
					System.out.println(tower.PegOne.toString());
				}
			}
			if(!tower.PegTwo.isEmpty()){
				if(tower.DragComponent == tower.PegTwo.peek().piece){
					try{
						System.out.println(tower.PegTwo.toString());
						temp = tower.PegTwo.peek();
						tower.PegTwo.pop();
						System.out.println("popped from two");
						temp.stackNumber = 1;
						tower.PegOne.push(temp);
						System.out.println("pushed into one");
						System.out.println(tower.PegOne.toString());
						System.out.println(tower.PegOne.topEntity);
						
						System.out.println("two");
						System.out.println(tower.PegTwo.toString());
						
					}catch(EmptyStackException _$e){
						System.err.println("Empty Stack exception... check code"+"\n"+ _$e.getMessage());
						return;
					}catch(MinLockException _$e){
						tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegTwo.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
						try{
							if(tower.PegTwo.isEmpty()){
								temp.stackNumber = 2;
								tower.PegTwo.topEntity = temp;
								tower.PegTwo.size++;
							}else{
								tower.PegTwo.peek().setNextNode(temp);
								temp.stackNumber = 2;
								tower.PegTwo.push(temp);
							}
						}catch(MinLockException _$f){
							System.out.println("We have a BIG PROBLEM");
						}
						return;
					}
					tower.DragComponent.setBounds(tower.pegOneX-5*(tower.PegOne.peek().nodeValue-5), tower.gameYpos - 25*(tower.PegOne.size-1)-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					
					tower.DragComponent = null;
					tower.draggedFrom = null;	
				}
			}
				if(!tower.PegThree.isEmpty()){
					if(tower.DragComponent == tower.PegThree.peek().piece){
						try{
							System.out.println("three");
							System.out.println(tower.PegThree.toString());
							temp = tower.PegThree.peek();
							tower.PegThree.pop();
							System.out.println("popped from three");
							temp.stackNumber = 1;
							tower.PegOne.push(temp);
							System.out.println("pushed into one");
							System.out.println(tower.PegOne.toString());
							System.out.println(tower.PegOne.topEntity);
							
							System.out.println("three");
							System.out.println(tower.PegThree.toString());
							
						}catch(EmptyStackException _$e){
							System.err.println("Empty Stack exception... check code"+"\n"+ _$e.getMessage());
							return;
						}catch(MinLockException _$e){
							tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegThree.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
							try{
								if(tower.PegThree.isEmpty()){
									temp.stackNumber = 3;
									tower.PegThree.topEntity = temp;
									tower.PegThree.size++;
								}else{
									tower.PegThree.peek().setNextNode(temp);
									temp.stackNumber = 3;
									tower.PegThree.push(temp);
								}
							}catch(MinLockException _$f){
								System.out.println("We have a BIG PROBLEM");
							}
							return;
						}
						tower.DragComponent.setBounds(tower.pegOneX-5*(tower.PegOne.peek().nodeValue-5), tower.gameYpos - 25*(tower.PegOne.size-1)-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
						
						tower.DragComponent = null;
						tower.draggedFrom = null;	
					}
					
				}
			temp = null;
			break;
		}
		case 0xFF404040: // For stack 2
		{
			System.out.println("0xFF3F4040");
			if(!tower.PegOne.isEmpty()){
				if(tower.DragComponent == tower.PegOne.peek().piece){
					try{
						System.out.println(tower.PegOne.toString());
						temp = tower.PegOne.peek();
						tower.PegOne.pop();
						System.out.println("popped from one");
						temp.stackNumber = 2;
						tower.PegTwo.push(temp);
						System.out.println("pushed into two");
						System.out.println(tower.PegTwo.toString());
						System.out.println(tower.PegTwo.topEntity);
						
						System.out.println("one");
						System.out.println(tower.PegOne.toString());
						
					}catch(EmptyStackException _$e){
						System.err.println("Empty Stack exception... check code"+"\n"+ _$e.getMessage());
						return;
					}catch(MinLockException _$e){
						tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegOne.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
						try{
							if(tower.PegOne.isEmpty()){
								temp.stackNumber = 1;
								tower.PegOne.topEntity = temp;
								tower.PegOne.size++;
								System.out.println(tower.PegOne.toString());
								System.out.println(tower.PegOne.topEntity);
							}else{
								tower.PegOne.peek().setNextNode(temp);
								temp.stackNumber = 1;
								tower.PegOne.push(temp);
							}
						}catch(MinLockException _$f){
							System.out.println("We have a BIG PROBLEM");
						}
						return;
					}
					tower.DragComponent.setLocation(tower.pegTwoX-5*(tower.PegTwo.peek().nodeValue-5), tower.gameYpos - 25*(tower.PegTwo.size-1)-tower.yAdjustment);
					
					tower.DragComponent = null;
					tower.draggedFrom = null;
				}
			}
			if(!tower.PegTwo.isEmpty()){
				if(tower.DragComponent == tower.PegTwo.peek().piece){
					tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegTwo.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					tower.DragComponent = null;
					tower.draggedFrom = null;
					System.out.println(tower.PegTwo.toString());
				}
			}
			if(!tower.PegThree.isEmpty()){
				if(tower.DragComponent == tower.PegThree.peek().piece){
					try{
						System.out.println(tower.PegThree.toString());
						temp = tower.PegThree.peek();
						tower.PegThree.pop();
						System.out.println("popped from three");
						temp.stackNumber = 2;
						tower.PegTwo.push(temp);
						System.out.println("pushed into two");
						System.out.println(tower.PegTwo.toString());
						System.out.println(tower.PegTwo.topEntity);
						
						System.out.println("three");
						System.out.println(tower.PegThree.toString());
						
					}catch(EmptyStackException _$e){
						System.err.println("Empty Stack exception... check code"+"\n"+ _$e.getMessage());
						return;
					}catch(MinLockException _$e){
						tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegThree.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
						try{
							if(tower.PegThree.isEmpty()){
								temp.stackNumber = 3;
								tower.PegThree.topEntity = temp;
								tower.PegThree.size++;
								
							}else{
								tower.PegThree.peek().setNextNode(temp);
								temp.stackNumber = 3;
								tower.PegThree.push(temp);
							}
						}catch(MinLockException _$f){
							System.out.println("We have a BIG PROBLEM");
						}
						return;
					}
				
					tower.DragComponent.setBounds(tower.pegTwoX-5*(tower.PegTwo.peek().nodeValue-5), tower.gameYpos - 25*(tower.PegTwo.size-1)-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					
					tower.DragComponent = null;
					tower.draggedFrom = null;	
				}
				
			}
			temp = null;
			break;
			
		}
		
		case 0xFF000000: // For stack 3
		{
			System.out.println("0xFF000000");
			if(!tower.PegOne.isEmpty()){
				if(tower.DragComponent == tower.PegOne.peek().piece){
					try{
						System.out.println(tower.PegOne.toString());
						temp = tower.PegOne.peek();
						tower.PegOne.pop();
						System.out.println("popped from one");
						temp.stackNumber = 3;
						tower.PegThree.push(temp);
						System.out.println("pushed into three");
						System.out.println(tower.PegThree.toString());
						System.out.println(tower.PegThree.topEntity);
						
						System.out.println("one");
						System.out.println(tower.PegOne.toString());
						
					}catch(EmptyStackException _$e){
						System.err.println("Empty Stack exception... check code"+"\n"+ _$e.getMessage());
						return;
					}catch(MinLockException _$e){
						tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegOne.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
						try{
							if(tower.PegOne.isEmpty()){
								temp.stackNumber = 1;
								tower.PegOne.topEntity = temp;
								tower.PegOne.size++;
							}else{
								tower.PegOne.peek().setNextNode(temp);
								temp.stackNumber = 1;
								tower.PegOne.push(temp);
							}
						}catch(MinLockException _$f){
							System.out.println("We have a BIG PROBLEM");
						}
						return;
					}
					tower.DragComponent.setBounds(tower.pegThreeX-5*(tower.PegThree.peek().nodeValue-5), tower.gameYpos - 25*(tower.PegThree.size-1)-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					
					tower.DragComponent = null;
					tower.draggedFrom = null;	
				}
			}
			if(!tower.PegThree.isEmpty()){
				if(tower.DragComponent == tower.PegThree.peek().piece){
					tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegThree.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					tower.DragComponent = null;
					tower.draggedFrom = null;
					System.out.println(tower.PegThree.toString());
				}
			}
			if(!tower.PegTwo.isEmpty()){
				if(tower.DragComponent == tower.PegTwo.peek().piece){
					try{
						System.out.println(tower.PegTwo.toString());
						temp = tower.PegTwo.peek();
						tower.PegTwo.pop();
						System.out.println("popped from two");
						temp.stackNumber = 3;
						tower.PegThree.push(temp);
						System.out.println("pushed into three");
						System.out.println(tower.PegThree.toString());
						System.out.println(tower.PegThree.topEntity);
						
						System.out.println("two");
						System.out.println(tower.PegTwo.toString());
						
					}catch(EmptyStackException _$e){
						System.err.println("Empty Stack exception... check code"+"\n"+ _$e.getMessage());
						return;
					}catch(MinLockException _$e){
						tower.DragComponent.setBounds(tower.draggedFrom.xPos-5*(tower.PegTwo.peek().nodeValue-5), tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
						try{
							if(tower.PegTwo.isEmpty()){
								temp.stackNumber = 2;
								tower.PegTwo.topEntity = temp;
								tower.PegTwo.size++;
							}else{
								tower.PegTwo.peek().setNextNode(temp);
								temp.stackNumber = 2;
								tower.PegTwo.push(temp);
							}
						}catch(MinLockException _$f){
							System.out.println("We have a BIG PROBLEM");
						}
						return;
					}
					tower.DragComponent.setBounds(tower.pegThreeX-5*(tower.PegThree.peek().nodeValue-5), tower.gameYpos - 25*(tower.PegThree.size-1)-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
					
					tower.DragComponent = null;
					tower.draggedFrom = null;
				}
					
			}
			temp = null;
			break;
			
		}
		case 0xFFFFFFFF: // Whoops... i missed...
		{
			System.out.println("0xFFCFDFFE");
			if(tower.DragComponent == null){
				System.out.println("Ive got nothing");
				break;
			}
			tower.DragComponent.setBounds(tower.draggedFrom.xPos-tower.xAdjustment, tower.draggedFrom.yPos-tower.yAdjustment, tower.DragComponent.getWidth(), tower.DragComponent.getHeight());
			tower.DragComponent = null;
			tower.draggedFrom = null;
			break;
		}
		}
		
		
	}
	
}
